using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB{
    /// <summary>
    /// Strongly-typed collection for the VwApplySafty class.
    /// </summary>
    [Serializable]
    public partial class VwApplySaftyCollection : ReadOnlyList<VwApplySafty, VwApplySaftyCollection>
    {        
        public VwApplySaftyCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_apply_safty view.
    /// </summary>
    [Serializable]
    public partial class VwApplySafty : ReadOnlyRecord<VwApplySafty>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_apply_safty", TableType.View, DataService.GetInstance("CXDB"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
                colvarId.ColumnName = "ID";
                colvarId.DataType = DbType.Int32;
                colvarId.MaxLength = 0;
                colvarId.AutoIncrement = false;
                colvarId.IsNullable = false;
                colvarId.IsPrimaryKey = false;
                colvarId.IsForeignKey = false;
                colvarId.IsReadOnly = false;
                
                schema.Columns.Add(colvarId);
                
                TableSchema.TableColumn colvarUid = new TableSchema.TableColumn(schema);
                colvarUid.ColumnName = "uid";
                colvarUid.DataType = DbType.Int32;
                colvarUid.MaxLength = 0;
                colvarUid.AutoIncrement = false;
                colvarUid.IsNullable = true;
                colvarUid.IsPrimaryKey = false;
                colvarUid.IsForeignKey = false;
                colvarUid.IsReadOnly = false;
                
                schema.Columns.Add(colvarUid);
                
                TableSchema.TableColumn colvarGuid = new TableSchema.TableColumn(schema);
                colvarGuid.ColumnName = "Guid";
                colvarGuid.DataType = DbType.Guid;
                colvarGuid.MaxLength = 0;
                colvarGuid.AutoIncrement = false;
                colvarGuid.IsNullable = true;
                colvarGuid.IsPrimaryKey = false;
                colvarGuid.IsForeignKey = false;
                colvarGuid.IsReadOnly = false;
                
                schema.Columns.Add(colvarGuid);
                
                TableSchema.TableColumn colvarReason = new TableSchema.TableColumn(schema);
                colvarReason.ColumnName = "Reason";
                colvarReason.DataType = DbType.String;
                colvarReason.MaxLength = 500;
                colvarReason.AutoIncrement = false;
                colvarReason.IsNullable = true;
                colvarReason.IsPrimaryKey = false;
                colvarReason.IsForeignKey = false;
                colvarReason.IsReadOnly = false;
                
                schema.Columns.Add(colvarReason);
                
                TableSchema.TableColumn colvarTbname = new TableSchema.TableColumn(schema);
                colvarTbname.ColumnName = "tbname";
                colvarTbname.DataType = DbType.String;
                colvarTbname.MaxLength = 50;
                colvarTbname.AutoIncrement = false;
                colvarTbname.IsNullable = true;
                colvarTbname.IsPrimaryKey = false;
                colvarTbname.IsForeignKey = false;
                colvarTbname.IsReadOnly = false;
                
                schema.Columns.Add(colvarTbname);
                
                TableSchema.TableColumn colvarCountTimes = new TableSchema.TableColumn(schema);
                colvarCountTimes.ColumnName = "CountTimes";
                colvarCountTimes.DataType = DbType.Int32;
                colvarCountTimes.MaxLength = 0;
                colvarCountTimes.AutoIncrement = false;
                colvarCountTimes.IsNullable = true;
                colvarCountTimes.IsPrimaryKey = false;
                colvarCountTimes.IsForeignKey = false;
                colvarCountTimes.IsReadOnly = false;
                
                schema.Columns.Add(colvarCountTimes);
                
                TableSchema.TableColumn colvarStatus = new TableSchema.TableColumn(schema);
                colvarStatus.ColumnName = "Status";
                colvarStatus.DataType = DbType.Int32;
                colvarStatus.MaxLength = 0;
                colvarStatus.AutoIncrement = false;
                colvarStatus.IsNullable = true;
                colvarStatus.IsPrimaryKey = false;
                colvarStatus.IsForeignKey = false;
                colvarStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarStatus);
                
                TableSchema.TableColumn colvarInTime = new TableSchema.TableColumn(schema);
                colvarInTime.ColumnName = "inTime";
                colvarInTime.DataType = DbType.DateTime;
                colvarInTime.MaxLength = 0;
                colvarInTime.AutoIncrement = false;
                colvarInTime.IsNullable = true;
                colvarInTime.IsPrimaryKey = false;
                colvarInTime.IsForeignKey = false;
                colvarInTime.IsReadOnly = false;
                
                schema.Columns.Add(colvarInTime);
                
                TableSchema.TableColumn colvarBossID = new TableSchema.TableColumn(schema);
                colvarBossID.ColumnName = "BossID";
                colvarBossID.DataType = DbType.Int32;
                colvarBossID.MaxLength = 0;
                colvarBossID.AutoIncrement = false;
                colvarBossID.IsNullable = true;
                colvarBossID.IsPrimaryKey = false;
                colvarBossID.IsForeignKey = false;
                colvarBossID.IsReadOnly = false;
                
                schema.Columns.Add(colvarBossID);
                
                TableSchema.TableColumn colvarBossNod = new TableSchema.TableColumn(schema);
                colvarBossNod.ColumnName = "BossNod";
                colvarBossNod.DataType = DbType.Int32;
                colvarBossNod.MaxLength = 0;
                colvarBossNod.AutoIncrement = false;
                colvarBossNod.IsNullable = true;
                colvarBossNod.IsPrimaryKey = false;
                colvarBossNod.IsForeignKey = false;
                colvarBossNod.IsReadOnly = false;
                
                schema.Columns.Add(colvarBossNod);
                
                TableSchema.TableColumn colvarBossTime = new TableSchema.TableColumn(schema);
                colvarBossTime.ColumnName = "BossTime";
                colvarBossTime.DataType = DbType.DateTime;
                colvarBossTime.MaxLength = 0;
                colvarBossTime.AutoIncrement = false;
                colvarBossTime.IsNullable = true;
                colvarBossTime.IsPrimaryKey = false;
                colvarBossTime.IsForeignKey = false;
                colvarBossTime.IsReadOnly = false;
                
                schema.Columns.Add(colvarBossTime);
                
                TableSchema.TableColumn colvarUserTime = new TableSchema.TableColumn(schema);
                colvarUserTime.ColumnName = "userTime";
                colvarUserTime.DataType = DbType.DateTime;
                colvarUserTime.MaxLength = 0;
                colvarUserTime.AutoIncrement = false;
                colvarUserTime.IsNullable = true;
                colvarUserTime.IsPrimaryKey = false;
                colvarUserTime.IsForeignKey = false;
                colvarUserTime.IsReadOnly = false;
                
                schema.Columns.Add(colvarUserTime);
                
                TableSchema.TableColumn colvarSaftyMasterStatus = new TableSchema.TableColumn(schema);
                colvarSaftyMasterStatus.ColumnName = "Safty_Master_Status";
                colvarSaftyMasterStatus.DataType = DbType.Int32;
                colvarSaftyMasterStatus.MaxLength = 0;
                colvarSaftyMasterStatus.AutoIncrement = false;
                colvarSaftyMasterStatus.IsNullable = true;
                colvarSaftyMasterStatus.IsPrimaryKey = false;
                colvarSaftyMasterStatus.IsForeignKey = false;
                colvarSaftyMasterStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarSaftyMasterStatus);
                
                TableSchema.TableColumn colvarDeptMasterStatus = new TableSchema.TableColumn(schema);
                colvarDeptMasterStatus.ColumnName = "Dept_Master_Status";
                colvarDeptMasterStatus.DataType = DbType.Int32;
                colvarDeptMasterStatus.MaxLength = 0;
                colvarDeptMasterStatus.AutoIncrement = false;
                colvarDeptMasterStatus.IsNullable = true;
                colvarDeptMasterStatus.IsPrimaryKey = false;
                colvarDeptMasterStatus.IsForeignKey = false;
                colvarDeptMasterStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarDeptMasterStatus);
                
                TableSchema.TableColumn colvarBossStatus = new TableSchema.TableColumn(schema);
                colvarBossStatus.ColumnName = "Boss_Status";
                colvarBossStatus.DataType = DbType.Int32;
                colvarBossStatus.MaxLength = 0;
                colvarBossStatus.AutoIncrement = false;
                colvarBossStatus.IsNullable = true;
                colvarBossStatus.IsPrimaryKey = false;
                colvarBossStatus.IsForeignKey = false;
                colvarBossStatus.IsReadOnly = false;
                
                schema.Columns.Add(colvarBossStatus);
                
                TableSchema.TableColumn colvarRepUsername = new TableSchema.TableColumn(schema);
                colvarRepUsername.ColumnName = "rep_username";
                colvarRepUsername.DataType = DbType.String;
                colvarRepUsername.MaxLength = 50;
                colvarRepUsername.AutoIncrement = false;
                colvarRepUsername.IsNullable = true;
                colvarRepUsername.IsPrimaryKey = false;
                colvarRepUsername.IsForeignKey = false;
                colvarRepUsername.IsReadOnly = false;
                
                schema.Columns.Add(colvarRepUsername);
                
                TableSchema.TableColumn colvarRepUserdeptname = new TableSchema.TableColumn(schema);
                colvarRepUserdeptname.ColumnName = "rep_userdeptname";
                colvarRepUserdeptname.DataType = DbType.String;
                colvarRepUserdeptname.MaxLength = 50;
                colvarRepUserdeptname.AutoIncrement = false;
                colvarRepUserdeptname.IsNullable = true;
                colvarRepUserdeptname.IsPrimaryKey = false;
                colvarRepUserdeptname.IsForeignKey = false;
                colvarRepUserdeptname.IsReadOnly = false;
                
                schema.Columns.Add(colvarRepUserdeptname);
                
                TableSchema.TableColumn colvarApplyUsername = new TableSchema.TableColumn(schema);
                colvarApplyUsername.ColumnName = "apply_username";
                colvarApplyUsername.DataType = DbType.String;
                colvarApplyUsername.MaxLength = 50;
                colvarApplyUsername.AutoIncrement = false;
                colvarApplyUsername.IsNullable = true;
                colvarApplyUsername.IsPrimaryKey = false;
                colvarApplyUsername.IsForeignKey = false;
                colvarApplyUsername.IsReadOnly = false;
                
                schema.Columns.Add(colvarApplyUsername);
                
                TableSchema.TableColumn colvarApplyUserdeptname = new TableSchema.TableColumn(schema);
                colvarApplyUserdeptname.ColumnName = "apply_userdeptname";
                colvarApplyUserdeptname.DataType = DbType.String;
                colvarApplyUserdeptname.MaxLength = 50;
                colvarApplyUserdeptname.AutoIncrement = false;
                colvarApplyUserdeptname.IsNullable = true;
                colvarApplyUserdeptname.IsPrimaryKey = false;
                colvarApplyUserdeptname.IsForeignKey = false;
                colvarApplyUserdeptname.IsReadOnly = false;
                
                schema.Columns.Add(colvarApplyUserdeptname);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["CXDB"].AddSchema("vw_apply_safty",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public VwApplySafty()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public VwApplySafty(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public VwApplySafty(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public VwApplySafty(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("Id")]
        [Bindable(true)]
        public int Id 
	    {
		    get
		    {
			    return GetColumnValue<int>("ID");
		    }
            set 
		    {
			    SetColumnValue("ID", value);
            }
        }
	      
        [XmlAttribute("Uid")]
        [Bindable(true)]
        public int? Uid 
	    {
		    get
		    {
			    return GetColumnValue<int?>("uid");
		    }
            set 
		    {
			    SetColumnValue("uid", value);
            }
        }
	      
        [XmlAttribute("Guid")]
        [Bindable(true)]
        public Guid? Guid 
	    {
		    get
		    {
			    return GetColumnValue<Guid?>("Guid");
		    }
            set 
		    {
			    SetColumnValue("Guid", value);
            }
        }
	      
        [XmlAttribute("Reason")]
        [Bindable(true)]
        public string Reason 
	    {
		    get
		    {
			    return GetColumnValue<string>("Reason");
		    }
            set 
		    {
			    SetColumnValue("Reason", value);
            }
        }
	      
        [XmlAttribute("Tbname")]
        [Bindable(true)]
        public string Tbname 
	    {
		    get
		    {
			    return GetColumnValue<string>("tbname");
		    }
            set 
		    {
			    SetColumnValue("tbname", value);
            }
        }
	      
        [XmlAttribute("CountTimes")]
        [Bindable(true)]
        public int? CountTimes 
	    {
		    get
		    {
			    return GetColumnValue<int?>("CountTimes");
		    }
            set 
		    {
			    SetColumnValue("CountTimes", value);
            }
        }
	      
        [XmlAttribute("Status")]
        [Bindable(true)]
        public int? Status 
	    {
		    get
		    {
			    return GetColumnValue<int?>("Status");
		    }
            set 
		    {
			    SetColumnValue("Status", value);
            }
        }
	      
        [XmlAttribute("InTime")]
        [Bindable(true)]
        public DateTime? InTime 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("inTime");
		    }
            set 
		    {
			    SetColumnValue("inTime", value);
            }
        }
	      
        [XmlAttribute("BossID")]
        [Bindable(true)]
        public int? BossID 
	    {
		    get
		    {
			    return GetColumnValue<int?>("BossID");
		    }
            set 
		    {
			    SetColumnValue("BossID", value);
            }
        }
	      
        [XmlAttribute("BossNod")]
        [Bindable(true)]
        public int? BossNod 
	    {
		    get
		    {
			    return GetColumnValue<int?>("BossNod");
		    }
            set 
		    {
			    SetColumnValue("BossNod", value);
            }
        }
	      
        [XmlAttribute("BossTime")]
        [Bindable(true)]
        public DateTime? BossTime 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("BossTime");
		    }
            set 
		    {
			    SetColumnValue("BossTime", value);
            }
        }
	      
        [XmlAttribute("UserTime")]
        [Bindable(true)]
        public DateTime? UserTime 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("userTime");
		    }
            set 
		    {
			    SetColumnValue("userTime", value);
            }
        }
	      
        [XmlAttribute("SaftyMasterStatus")]
        [Bindable(true)]
        public int? SaftyMasterStatus 
	    {
		    get
		    {
			    return GetColumnValue<int?>("Safty_Master_Status");
		    }
            set 
		    {
			    SetColumnValue("Safty_Master_Status", value);
            }
        }
	      
        [XmlAttribute("DeptMasterStatus")]
        [Bindable(true)]
        public int? DeptMasterStatus 
	    {
		    get
		    {
			    return GetColumnValue<int?>("Dept_Master_Status");
		    }
            set 
		    {
			    SetColumnValue("Dept_Master_Status", value);
            }
        }
	      
        [XmlAttribute("BossStatus")]
        [Bindable(true)]
        public int? BossStatus 
	    {
		    get
		    {
			    return GetColumnValue<int?>("Boss_Status");
		    }
            set 
		    {
			    SetColumnValue("Boss_Status", value);
            }
        }
	      
        [XmlAttribute("RepUsername")]
        [Bindable(true)]
        public string RepUsername 
	    {
		    get
		    {
			    return GetColumnValue<string>("rep_username");
		    }
            set 
		    {
			    SetColumnValue("rep_username", value);
            }
        }
	      
        [XmlAttribute("RepUserdeptname")]
        [Bindable(true)]
        public string RepUserdeptname 
	    {
		    get
		    {
			    return GetColumnValue<string>("rep_userdeptname");
		    }
            set 
		    {
			    SetColumnValue("rep_userdeptname", value);
            }
        }
	      
        [XmlAttribute("ApplyUsername")]
        [Bindable(true)]
        public string ApplyUsername 
	    {
		    get
		    {
			    return GetColumnValue<string>("apply_username");
		    }
            set 
		    {
			    SetColumnValue("apply_username", value);
            }
        }
	      
        [XmlAttribute("ApplyUserdeptname")]
        [Bindable(true)]
        public string ApplyUserdeptname 
	    {
		    get
		    {
			    return GetColumnValue<string>("apply_userdeptname");
		    }
            set 
		    {
			    SetColumnValue("apply_userdeptname", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string Id = @"ID";
            
            public static string Uid = @"uid";
            
            public static string Guid = @"Guid";
            
            public static string Reason = @"Reason";
            
            public static string Tbname = @"tbname";
            
            public static string CountTimes = @"CountTimes";
            
            public static string Status = @"Status";
            
            public static string InTime = @"inTime";
            
            public static string BossID = @"BossID";
            
            public static string BossNod = @"BossNod";
            
            public static string BossTime = @"BossTime";
            
            public static string UserTime = @"userTime";
            
            public static string SaftyMasterStatus = @"Safty_Master_Status";
            
            public static string DeptMasterStatus = @"Dept_Master_Status";
            
            public static string BossStatus = @"Boss_Status";
            
            public static string RepUsername = @"rep_username";
            
            public static string RepUserdeptname = @"rep_userdeptname";
            
            public static string ApplyUsername = @"apply_username";
            
            public static string ApplyUserdeptname = @"apply_userdeptname";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
